//
// Created by 123 on 2025/1/8.
//
#include "list"
#include "algorithm"
#include "iostream"
using namespace std;

void printList(const list<int>& li){
    for(list<int>::const_iterator it = li.begin();it!= li.end();it++){
        cout << *it << " ";
    }
    cout << endl;
}

void test(){
    list<int> l1;
    l1.push_back(10);
    l1.push_back(20);
    l1.push_back(30);
    l1.push_back(40);
    printList(l1);

    list<int> l2;
    l2 = l1;
    printList(l2);

    list<int> l3;
    l3.assign(l2.begin(),l2.end());
    printList(l3);

    list<int> l4;
    l4.assign(10,100);
    printList(l4);

}

void test2(){
    list<int> l1;
    l1.push_back(10);
    l1.push_back(20);
    l1.push_back(30);

    list<int> l2;
    l2.assign(10,100);

    cout << "before swap==="<< endl;
    printList(l1);
    printList(l2);
    l1.swap(l2);
    cout << "after swap===" << endl;
    printList(l1);
    printList(l2);

    if(!l2.empty()){
        cout << "l2 is not empty" << endl;
        cout << "l2 size =" << l2.size() << endl;
    }
    cout << "resize===" << endl;
    l2.resize(10);
    printList(l2);
    cout << "resize again" << endl;
    l2.resize(20,999);
    printList(l2);
}

int main133(){
    test();
    test2();
    return 0;
}